package top.healthylife.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import top.healthylife.domain.OrderSetting;

import java.util.Date;
import java.util.List;

public interface OrderSettingMapper {
    @Select("select count(*) from t_ordersetting where orderDate = #{orderDate}")
    int isExistedOrderDate(Date orderDate);
    @Update("update t_ordersetting set number=#{number} where orderDate =#{orderDate}")
    void updateNumber(OrderSetting orderSetting);
    @Insert("insert into t_ordersetting (orderDate,number,reservations) " +
            "values (#{orderDate},#{number},#{reservations})")
    void insertNumber(OrderSetting orderSetting);

    List<OrderSetting> getOrderSettingByMonth(@Param("date") String date);

    /**
     * 根据预约日期查询是否已存在预约设置
     * @param date 预约日期
     * @return
     */
    @Select("select * from t_ordersetting where orderDate =#{date}")
    OrderSetting findByOrderDate(@Param("date") Date date);

    /**
     * 根据预约日期更新预约数量
     * @param orderSetting
     */
    @Update("update t_ordersetting set reservations = #{reservations} where orderDate " +
            "=#{orderDate}")
    void updateReservationByOrderDate(OrderSetting orderSetting);
}
